package com.hy.mydesktop.server.dao;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Query;

import org.springframework.stereotype.Component;

import com.hy.enterprise.framework.persistence.PersistentException;
import com.hy.enterprise.framework.persistence.api.MyAbstractDao;
import com.hy.mydesktop.client.component.type.ComponentControllerEnum;
import com.hy.mydesktop.shared.persistence.domain.gxt.GxtComponentControllerMetaModel;
import com.hy.mydesktop.shared.persistence.domain.gxt.GxtComponentControllerMetaNodeModel;
import com.hy.mydesktop.shared.persistence.domain.gxt.GxtComponentMetaNodeModel;
import com.hy.mydesktop.shared.persistence.domain.gxt.GxtAppEventType;
import com.hy.mydesktop.shared.persistence.domain.gxt.constant.MetaDataConstants;
import com.hy.mydesktop.shared.persistence.domain.util.ComponentControllerMetaModelUtil;
import com.hy.mydesktop.shared.persistence.domain.util.Persistable;

@Component("componentControllerMetaModelDao")
public class ComponentControllerMetaModelDaoImpl extends MyAbstractDao<GxtComponentControllerMetaModel> implements ComponentControllerMetaModelDao<GxtComponentControllerMetaModel> {
	
	
	
	/* (non-Javadoc)
	 * @see com.hy.mydesktop.server.dao.ComponentControllerMetaModelDao#persist(com.hy.mydesktop.shared.model.meta.GxtComponentControllerMetaNodeModel)
	 */

	
	@Override
	public boolean persist(GxtComponentControllerMetaModel persistentEntity)
			throws PersistentException {
//		return super.persist(persistentEntity);
		GxtComponentControllerMetaModel gxtComponentControllerMetaModel =ComponentControllerMetaModelUtil.reConstructGxtComponentControllerMetaModel(persistentEntity);
		return super.persist(gxtComponentControllerMetaModel);
	}



	@Override
	public String[] persist(
			GxtComponentControllerMetaModel... persistentEntities)
			throws PersistentException {
		// TODO Auto-generated method stub
		return super.persist(persistentEntities);
	}



	@Override
	public Integer persists(
			GxtComponentControllerMetaModel... persistentEntities)
			throws PersistentException {
		// TODO Auto-generated method stub
		return super.persists(persistentEntities);
	}



	public ComponentControllerMetaModelDaoImpl() {
		super();
		// TODO Auto-generated constructor stub
	}

	

	@Override
	public GxtComponentControllerMetaModel findByControllerMetaModelId(String controllerMetaModelId) {
		//return super.findById(controllerMetaModelId);
		//String queryString="select o from GxtComponentControllerMetaModel as o where o."+MetaDataConstants.COMPONENT_CONTROLLER_METAMODEL_ID+" = :controllerMetaModelId";
		//String queryString2="select o from GxtComponentControllerMetaModel as o where o.id"+" = :controllerMetaModelId";
		//Map<String, String> map = new HashMap<String, String>();
		//map.put("controllerMetaModelId", controllerMetaModelId);
		//return (GxtComponentControllerMetaModel)findUniqueResult(queryString2,map);
		return super.findById(controllerMetaModelId);
	}
	
	/*Map<String , Object> desktopController=new HashMap<String, Object>();
//	desktopController.put("component_controller_model_type", ComponentControllerEnum.DESKTOP_CONTROL_MODEL);
	desktopController.put("component_controller_model_type_index", ComponentControllerEnum.DESKTOP_CONTROLLOR_MODEL.ordinal());
	List<String> codes1 = new ArrayList<String>();
	codes1.add("0003");
	codes1.add("0002");
	codes1.add("0005");
	desktopController.put("registereventtypes", codes1);
	desktopController.put("id", "desktopController");
	GxtComponentMetaNodeModel node=new GxtComponentMetaNodeModel(desktopController,1,18);*/

}
